package com.sx.micowell.module.member

import android.view.View
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.mvvm.bar.OnTitleBarListener

import com.example.mvvm.base.ContainerActivity
import com.example.mvvm.base.action.TitleBarAction
import com.example.mvvm.base.data.DataBindingConfig
import com.example.mvvm.until.LogUtils
import com.gyf.immersionbar.ImmersionBar

import com.miloyu.modelnet.response.HelpInfoVO
import com.miloyu.modelnet.response.UserAgreementVO
import com.miloyu.modelnet.response.VipNotesVO
import com.sx.micowell.R
import com.sx.micowell.databinding.ActAgreementBinding
import com.sx.micowell.framework.app.IntentKey
import com.sx.micowell.framework.app.MyActivity
import com.sx.micowell.framework.app.MyFragment

import com.sx.micowell.framework.arouth.RoutePath
import com.sx.micowell.module.web.WebViewFragment

/**
 * @Author: YY
 * @Time: 2021/9/1
 * @Describe TODO
 */
@Route(path = RoutePath.MEMBER_AGREEMENT)
class MemberAgreementFragment: MyFragment<ActAgreementBinding, ContainerActivity>(),
    OnTitleBarListener {

    @Autowired(name = IntentKey.DATA)
    @JvmField
    var userAgreement : VipNotesVO? = null


    override fun getDataBindingConfig(): DataBindingConfig {
        return DataBindingConfig(R.layout.act_agreement)
    }

    override fun initView() {
        ImmersionBar.with(this).statusBarDarkFont(true)
            .fitsSystemWindows(true).init()
        binding.title.setOnTitleBarListener(this)
    }

    override fun initData() {
        loadRootFragment(userAgreement)
    }

    private fun loadRootFragment(data: VipNotesVO?) {
        LogUtils.d("loadRootFragment ${data?.vipNotes}")
        fragmentManager?.beginTransaction()?.add(R.id.fl_container,
            WebViewFragment.newInstance("", data?.vipNotes)
        )?.commit()
    }

    override fun onLeftClick(view: View?) {
        myActivity.finish()
    }

    override fun onTitleClick(view: View?) {
    }

    override fun onRightClick(view: View?) {
    }


}